/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ar.edu.unicen.twitter.suggest.backend.dtos;

import ar.edu.unicen.twitter.suggest.commons.dtos.Usuario;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 *
 * Clase contenedora, posee tres campos, referencias a otros objetos
 * exceptuando por el id, los campos restantes son lazy (pueden no conocerse aun,
 * o bien conocerse pero no haberse recuperado de la BD)
 * 
 */
public class UsuarioApi extends Usuario{
       
    long id;
    UsuarioBasico usuarioBasico;
    List<TweetApi> tw = new ArrayList<TweetApi>();
    long[] fws = null;
    long[] fwers = null;
    
    //flags: no es posible asignar null a los arreglos, por lo que se debe
    //utilizar un flag para diferenciar entre no cargado, y vacío
    boolean usuarioBasicoValido;
    boolean tweetsValidos;
    boolean followsValidos;
    boolean followersValidos;
    
    public UsuarioApi(long id2)
    {   this.id= id2;
        usuarioBasico = null;
        usuarioBasicoValido=false;
        tweetsValidos=false;
        followsValidos =false;
        followersValidos = false;
    }
    
    public UsuarioApi(UsuarioBasico usuarioBasico)
    {   this.id =(usuarioBasico.getId());
        this.usuarioBasico = usuarioBasico;
        usuarioBasicoValido=true;
        tweetsValidos=false;
        followsValidos =false;
        followersValidos = false;
    }

    public List<TweetApi> getTweets()
    {   return getTw();
    }


    @Override
    public int getFollowsCount() {
        if(getUsuarioBasico()==null)
            return 0;
        return getUsuarioBasico().getFriendsCount();
    }

    @Override
    public int getFollowersCount() {
        if(getUsuarioBasico()==null)
            return 0;
        return getUsuarioBasico().getFollowersCount();
    }

    @Override
    public int getTweetsCount() {
        if(getUsuarioBasico()==null)
            return 0;
        return getUsuarioBasico().getStatusesCount();
    }
    @Override
    public String getScreenName()
    {
        if(getUsuarioBasico()!=null)
            return getUsuarioBasico().getScreenName();
        else return "";
    }

    @Override
    public boolean equals(Object o1)
    {
        if(o1 instanceof Usuario && id == ((Usuario)o1).getId())
            return true;
        return false;
    }

    @Override
    public long getId() {
        return id;
    }

    @Override
    public int hashCode() {
        return Usuario.calculateHashCode(id);
    }

    @Override
    public String toString() {
        return "["+id+"]"+"("+getUsuarioBasico()+"):"+getMentions()+"m, "+getScore()+"sc";
    }

    
    public String getName() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getLocation() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getDescription() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isContributorsEnabled() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public URL getProfileImageURL() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public URL getURL() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isProtected() {
        if(usuarioBasico!=null)
            return usuarioBasico.isProtected();
        else
            return true;
    }


    public Date getStatusCreatedAt() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public long getStatusId() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getStatusText() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getStatusSource() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isStatusTruncated() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public long getStatusInReplyToStatusId() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public long getStatusInReplyToUserId() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isStatusFavorited() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getStatusInReplyToScreenName() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getProfileBackgroundColor() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getProfileTextColor() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getProfileLinkColor() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getProfileSidebarFillColor() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getProfileSidebarBorderColor() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public int getFriendsCount() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Date getCreatedAt() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public int getFavouritesCount() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public int getUtcOffset() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getTimeZone() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getProfileBackgroundImageUrl() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isProfileBackgroundTiled() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getLang() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public int getStatusesCount() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isGeoEnabled() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isVerified() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
//hibernate
    UsuarioApi(){
    }
    void setId(long id){
        this.id=id;
    }
    void setUsuarioBasico(UsuarioBasico ub){
        this.usuarioBasico =ub;
    }
    UsuarioBasico getUsuarioBasico(){      
        return usuarioBasico;
    }
    List<TweetApi> getTw(){
        return tw;
    }
    void setTw(List<TweetApi> tweets){
        this.tw = tweets;
    }
    
    void setUsuarioBasicoValido(boolean b) {
        usuarioBasicoValido=b;
    }

    void setTweetsValidos(boolean b) {
        tweetsValidos =b;
    }
    boolean getUsuarioBasicoValido() {
        return usuarioBasicoValido;
    }
    boolean getTweetsValidos() {
        return tweetsValidos;
    }
    void setFws(long[] follows) {
        this.fws = follows;
    }
    void setFwers(long[] followers) {
        this.fwers = followers;
    }
    long[] getFws() {
        return fws;
    }

    long[] getFwers() {
        return fwers;
    }
    boolean getFollowersValidos(){
        return followersValidos;
    }
    void setFollowersValidos(boolean b) {
        this.followersValidos = b;
    }
    boolean getFollowsValidos(){
        return followsValidos;
    }
    void setFollowsValidos(boolean b) {
        this.followsValidos = b;
    }

    @Override
    public long[] getFollowersIds() {
       return fwers;
    }

    @Override
    public long[] getFollowsIds() {
       return fws;
    }

    @Override
    public Collection<Usuario> getFollowers() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public Collection<Usuario> getFollows() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
